package com.boot.core.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author Cheng JiYe
 * @description: swagger 访问路径 http://ip:端口/项目名称/swagger-ui.html
 * http://localhost:8083/boot/swagger-ui.html
 * @date 2020/10/2 18:19
 */
@Configuration
public class SwaggerConfig {
  @Bean
  public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
        .apiInfo(apiInfo())
        .select()
        .apis(RequestHandlerSelectors.basePackage("com.boot.controller"))
        .paths(PathSelectors.any())
        .build();
  }

  private ApiInfo apiInfo() {
    return new ApiInfoBuilder()
        .title("xxx管理后台接口文档")
        .description("《本文档由xxx个人提供》")
        .termsOfServiceUrl("")
        .version("1.0")
        .build();
  }
}
